#include "port.h"

static port_event_handle_t m_key_handle = NULL;
static port_handle_t m_init_handle = NULL;

void port_set_btn_handle(port_event_handle_t handle) { m_key_handle = handle; }

void port_btn_handle(uint32_t btnID) {
  if (m_key_handle != NULL) {
    m_key_handle(btnID);
  }
}

void port_set_init_handle(port_handle_t handle) { m_init_handle = handle; }

void port_init_handle() {
  if (m_init_handle != NULL) {
    m_init_handle();
  } else {
#if SCREEN_BUFFER_COLOR_DEPTH == 1
    for (int i = 0; i < SCREEN_BUFFER_WIDTH; i++) {
      frame_buffer[i / 8][i] = 0x55;
    }
#elif SCREEN_BUFFER_COLOR_DEPTH == 8
#elif SCREEN_BUFFER_COLOR_DEPTH == 16
#elif SCREEN_BUFFER_COLOR_DEPTH == 24
    for (int i = 0; i < SCREEN_BUFFER_WIDTH; i++) {
      rgb[i / 2][i][0] = 0x35;
    }
#endif /* SCREEN_BUFFER_COLOR_DEPTH  */
  }
}